package com.jnc.plug.mybatis.mp.generator;

import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.jnc.plug.mybatis.mp.generator.config.*;

import java.util.Properties;

/**
 * @Description
 * @Author fanlei
 * @Version 1.0
 * @Date 2019/9/28
 */
public class MyBatisPlusGenerator {

    private Properties properties;

    public MyBatisPlusGenerator(Properties properties){
        this.properties = properties;
    }

    public void generate(){
        Context.setConfig(properties);
        // 代码生成器
        AutoGenerator mpg = new AutoGenerator();
        // 全局配置
        new CustomGlobalConfig(mpg).invoke();
        // 数据源配置
        new CustomDataSourceConfig(mpg).invoke();
        // 策略配置
        new CustomStrategyConfig(mpg).invoke();

//        ConstVal.ENTITY_PATH
//        ConstVal.MAPPER_PATH
//        ConstVal.XML_PATH
//        ConstVal.SERVICE_PATH
//        ConstVal.SERVICE_IMPL_PATH
//        ConstVal.CONTROLLER_PATH
//        .setPathInfo()

        // 包配置
        new CustomPackageConfig(mpg).invoke();

        //模板
        new CustomTemplate(mpg).invoke();

        // 执行生成
        mpg.execute();
    }
}
